package com.xdclass.controller;

import com.xdclass.mapper.TCouponMapper;
import com.xdclass.model.TCoupon;
import com.xdclass.model.TCouponExample;
import com.xdclass.service.CouponService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName:TestController Package:com.xdclass.controller Description:
 *
 * @Date:2021/7/1 10:31
 * @Author:sunzheng@beiming.com
 */
@RestController
@RequestMapping("/test/api/v1")
public class TestController {

  @Resource
  private TCouponMapper tCouponMapper;

  @Resource
  private CouponService couponService;

  @GetMapping("/test")
  public String test() {
    System.out.println("我发生了改变");
    System.out.println("我是一个分支");
    System.out.println("Hello 您好！");
    return "222";
  }

  @GetMapping("/test1")
  public String test1() {
    TCouponExample example = new TCouponExample();
    example.createCriteria().andCodeEqualTo("50159f44-2b17-415c-920a-c67a9365f394");
    List<TCoupon> tCoupons = tCouponMapper.selectByExample(example);
    return tCoupons.get(0).toString();
  }

  @GetMapping("/getUser")
  public String getUserById(@RequestParam("id") Integer id) {
    return couponService.getUserById(id);
  }

}
